(function(){
    _$(document).ready(function(){
        function App(){};
        App.prototype.ajaxFn=function(){
            function rehtml(txt,info){
                var html="";
                for(var val in info){
                    info[val].typeName=txt;
                    info[val].index=parseInt(val)+1;
                    html += template('tpl', info[val]);
                }
                return html;
            }
            //风云榜
            _$.post('/getProminent',{type:'fyb'},function(data){
                if(data.code==1){
                    var info=data.info;
                    _$('#fyb').html(rehtml("原创风云榜",info));
                }
            });
            //畅销榜
            _$.post('/getProminent',{type:'cxb'},function(data){
                if(data.code==1){
                    var info=data.info;
                    _$('#cxb').html(rehtml("畅销榜",info));
                }
            });
            //点击榜
            _$.post('/getProminent',{type:'djb'},function(data){
                if(data.code==1){
                    var info=data.info;
                    _$('#djb').html(rehtml("点击榜",info));
                }
            });
            //推荐榜
            _$.post('/getProminent',{type:'tjb'},function(data){
                if(data.code==1){
                    var info=data.info;
                    _$('#tjb').html(rehtml("推荐榜",info));
                }
            });
            //打赏榜
            _$.post('/getProminent',{type:'dsb'},function(data){
                if(data.code==1){
                    var info=data.info;
                    _$('#dsb').html(rehtml("打赏榜",info));
                }
            });
            //更新榜
            _$.post('/getProminent',{type:'gxb'},function(data){
                if(data.code==1){
                    var info=data.info;
                    _$('#gxb').html(rehtml("更新榜",info));
                }
            });
            //签约榜
            _$.post('/getProminent',{type:'qyb'},function(data){
                if(data.code==1){
                    var info=data.info;
                    _$('#qyb').html(rehtml("签约榜",info));
                }
            });
        };
        App.prototype.eventFn=function(){

        };
        App.prototype.init=function(){
            //事件调用
            this.ajaxFn();
            this.eventFn();
        };
        //程序初始化
        new App().init();
    })
})();